﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Dc.Migrations
{
    /// <inheritdoc />
    public partial class addtableChrgitmTypeGrp : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameTable(
                name: "PUB_ITEM_TYPE",
                newName: "PUB_ITEM_TYPE",
                newSchema: "Dc");

            migrationBuilder.CreateTable(
                name: "CHRGITM_TYPE_GRP",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    CHRGITM_TYPE_GRP_CODE = table.Column<string>(type: "text", nullable: false),
                    CHRGITM_TYPE_GRP_NAME = table.Column<string>(type: "text", nullable: false),
                    DEF_FLAG = table.Column<bool>(type: "boolean", nullable: false),
                    VALI_FLAG = table.Column<bool>(type: "boolean", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CHRGITM_TYPE_GRP", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CHRGITM_TYPE",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    CHRGITM_TYPE_CODG = table.Column<string>(type: "text", nullable: false),
                    CHRGITM_TYPE_NAME = table.Column<string>(type: "text", nullable: false),
                    VALI_FLAG = table.Column<bool>(type: "boolean", nullable: false),
                    ChrgitmTypeGrpId = table.Column<Guid>(type: "uuid", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CHRGITM_TYPE", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CHRGITM_TYPE_CHRGITM_TYPE_GRP_ChrgitmTypeGrpId",
                        column: x => x.ChrgitmTypeGrpId,
                        principalSchema: "Dc",
                        principalTable: "CHRGITM_TYPE_GRP",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CHRGITM_TYPE_ChrgitmTypeGrpId",
                schema: "Dc",
                table: "CHRGITM_TYPE",
                column: "ChrgitmTypeGrpId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CHRGITM_TYPE",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "CHRGITM_TYPE_GRP",
                schema: "Dc");

            migrationBuilder.RenameTable(
                name: "PUB_ITEM_TYPE",
                schema: "Dc",
                newName: "PUB_ITEM_TYPE");
        }
    }
}
